package com.demo.controller.aircraft;

import com.demo.common.model.Aircraft;
import com.demo.service.AircraftService;
import com.demo.service.AirrouteService;
import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class AircraftrouteValiator extends Validator {

    @Inject
    AirrouteService airrouteService;

    @Override
    protected void validate(Controller controller) {
        validateRequiredString("aircraft.airrouteid", "airrouteidMsg", "请选择飞机航线!");
    }

    @Override
    protected void handleError(Controller controller) {
        controller.keepModel(Aircraft.class);

        String actionKey = getActionKey();
        controller.setAttr("routes",airrouteService.findAll());
        if (actionKey.equals("/aircraft/aircraftupdate"))
            controller.render("airroute.html");
    }
}
